package scm.quote.jaxb;

import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.io.StringWriter;

import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;

import org.apache.log4j.Logger;

import com.scm.integration.ScmMain;
import com.scm.property.FileProperties;
import com.scm.property.PropertyConfig;
import com.scm.property.IPropertyConfig;
import com.scm.utils.DataService;

public class JaxbXmlqut {
	
	private static Logger log = Logger.getLogger(JaxbXmlqut.class);
	
	public static String parserJaxb(SCMBean scmObject){
		JAXBContext context;
		try {
			context = JAXBContext.newInstance(SCMBean.class);
			StringWriter writer = new StringWriter();
			context.createMarshaller().marshal(scmObject, writer);
			
			IPropertyConfig property = new PropertyConfig();
			FileWriter filewriter = new FileWriter(property.getStringFileXMLquote());
		    BufferedWriter buffer = new BufferedWriter (filewriter);
			buffer.write(writer.toString());
			buffer.close();
			
			return writer.toString();
		} catch (JAXBException e) {
			log.error("Error:",e);
		} catch (IOException e) {
			log.error("Error:",e);
		}
		return null;
	}

}
